package com.wangc.study.functionref;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author wangC
 * @create 2020-05-19 下午11:38
 * @Description 方法的引用--构造方法的调用
 **/
public class FountionRefTest4 {

    public static void main(String[] args) {

        Supplier<Stu> s1 = () -> new Stu();
        Supplier<Stu> s2 = Stu::new;

        s1.get();
        s2.get();

        Supplier<List> s3 = ArrayList::new;
        Supplier<Set> s4 = HashSet::new;
        Supplier<Thread> s5 = Thread::new;

        Consumer<Integer> c1 = (integer -> new Tea(integer));
        c1.accept(1);

    }

}


class Stu{
    public Stu() {
        System.out.println("调用stu无参构造");
    }
}

class Tea{
    public Tea() {
        System.out.println("调用tea无参构造");

    }

    public Tea(Integer integer) {
        System.out.println("调用tea有参构造"+integer);
    }
}